package com.net.loaderManage.item
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.system.*;

    public class ImageLoaderItem extends Object
    {
        private var _url:String;
        private var _loader:Loader;
        private var _consumer:Function;

        public function ImageLoaderItem(param1:String, param2:Function)
        {
            _url = param1;
            _consumer = param2;
            var _loc_3:* = new LoaderContext(true);
            _loader = new Loader();
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandle);
            _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandle);
            _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandle);
            _loader.load(new URLRequest(param1), _loc_3);
            return;
        }// end function

        private function completeHandle(event:Event) : void
        {
            var _loc_2:Bitmap = null;
            if (_consumer != null)
            {
                _loc_2 = _loader.content as Bitmap;
                _consumer("success", _loc_2, this._url);
            }
            _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandle);
            _loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandle);
            _loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandle);
            _loader = null;
            return;
        }// end function

        private function progressHandle(event:ProgressEvent) : void
        {
            return;
        }// end function

        private function errorHandle(event:IOErrorEvent) : void
        {
            if (_consumer != null)
            {
                _consumer("error", null, this._url);
            }
            _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandle);
            _loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandle);
            _loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandle);
            _loader = null;
            return;
        }// end function

    }
}
